//
//  NSString+Valid.m
//  ITC_iOS
//
//  Created by iBenz on 2018/9/8.
//  Copyright © 2018年 Benz.L. All rights reserved.
//

#import "NSString+Valid.h"

@implementation NSString(Valid)
- (BOOL)isChinese {
    NSString *match=@"(^[\u4e00-\u9fa5]+$)";
    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF matches %@", match];
    return [predicate evaluateWithObject:self];
}
- (BOOL)isNumber {
    return [self inString:@"1234567890."];
}
- (BOOL)inString:(NSString *)specifiedString {
    if (!specifiedString) {
        return NO;
    }
    NSCharacterSet *cs = [[NSCharacterSet characterSetWithCharactersInString:specifiedString]invertedSet];
    NSString *filtered = [[self componentsSeparatedByCharactersInSet:cs]componentsJoinedByString:@""];
    return [self isEqualToString:filtered];
}

@end
